using System.CodeDom;
using System.CodeDom.Compiler;
using System.IO;
using Microsoft.CSharp;
using NUnitGenAddIn.Core;

namespace NUnitGenAddIn.VS2008
{
    /// <summary>
    /// VS2008 Code Dom Helper
    /// </summary>
    public class VS2008CodeDomHelper : CodeDomHelper
    {
        /// <summary>
        /// Parses the specified code stream.
        /// </summary>
        /// <param name="codeStream">The code stream.</param>
        /// <returns><see cref="CodeCompileUnit"/> object</returns>
        public override CodeCompileUnit Parse(TextReader codeStream)
        {
            return new CSharpCodeProvider().Parse(codeStream);
        }

        /// <summary>
        /// Generates the code from compile unit.
        /// </summary>
        /// <param name="compileUnit">The compile unit.</param>
        /// <param name="write">The write.</param>
        /// <param name="options">The options.</param>
        public override void GenerateCodeFromCompileUnit(CodeCompileUnit compileUnit, TextWriter write,
                                                         CodeGeneratorOptions options)
        {
            new CSharpCodeProvider().GenerateCodeFromCompileUnit(compileUnit, write, options);
        }

        /// <summary>
        /// Generates the code from statement.
        /// </summary>
        /// <param name="statement">The statement.</param>
        /// <param name="writer">The writer.</param>
        /// <param name="options">The options.</param>
        public override void GenerateCodeFromStatement(CodeStatement statement, TextWriter writer,
                                                       CodeGeneratorOptions options)
        {
            new CSharpCodeProvider().GenerateCodeFromStatement(statement, writer, options);
        }

        /// <summary>
        /// Generates the code from <c>Namespace</c>.
        /// </summary>
        /// <param name="codeNamespace">The code <c>Namespace</c>.</param>
        /// <param name="writer">The writer.</param>
        /// <param name="options">The options.</param>
        public override void GenerateCodeFromNameSpace(CodeNamespace codeNamespace, TextWriter writer,
                                                       CodeGeneratorOptions options)
        {
            new CSharpCodeProvider().GenerateCodeFromNamespace(codeNamespace, writer, options);
        }
    }
}